<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>设备管理</title>
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/echarts.min.js"></script>
	</head>
	<body>
		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="addReturn()">
			<p style="color: white;size: 16px;">修改设备信息</p>
		</div>
		<form  id="form1" target="ifr">
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备类型</div>
			</div>
			<div class="moban-lb-r">
				<p id="noApplicationRecord" style="margin-top: 10px;">
				</p>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备序列号</div>
			</div>
			<div class="moban-lb-r">
				<input  id="deviceSN" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color=''}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">
			</div>
			<div class="clear"></div>
		</div>
		<div id="equipment"></div>
		<div id="equipment1"></div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">状态</div>
			</div>
			<div class="moban-lb-r">
				<select id="deviceStatusID">
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<!--<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备IP</div>
			</div>
			<div class="moban-lb-r">
				<input id="equipment11" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color=''}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备端口号</div>
			</div>
			<div class="moban-lb-r">
				<input id="equipment12" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color=''}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">
			<div class="clear"></div>
		</div>-->
		<!--<div class="moban-lb">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">使用情况</div>    	     		
     	</div>
     	<div class="moban-lb-r">
     		 <input id="use" type="text" value="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:#cdcdcd;" class="shuru-jine">  		
     	</div>
     	<div class="clear"></div>
     </div>-->
		<div class="tijiao">
			<input type="submit" class="tijiao-btn" value="提交">
		</div>
		</form>
		<iframe name='ifr' id="ifr" style='display: none;'></iframe><!--表单提交防止刷新-->
		<!--封装同步异步请求-->
		<script  charset="UTF-8" src="js/simple.tool.js" ></script>
		<script>
			$("#form1").submit(function () {
				var map={};
				map.url="updateDevice";
				var devicetypeIdtemp=$("#noApplicationRecord").html();
				if (devicetypeIdtemp=='RFID阅读器'){
					map.devicetypeId=2;
				} else if (devicetypeIdtemp=='智能项圈') {
					map.devicetypeId=1;
				}
				var statusWorktemp=$("#deviceStatusID").val();
				if (statusWorktemp=='1'){
					map.statusWork='00A';
				} else if (statusWorktemp=='0') {
					map.statusWork='00X';
				}
				map.id =shebeiDeviceSN.deviceID;
				map.deviceSerial=$("#deviceSN").val();
				map.col2=$("#equipment14").val();
				map.ip=$("#equipment11").val();
				map.port=$("#equipment12").val();
				ajaxRequestPostEDS(function (data) {
					equipments();
				},map)
			});
			var deviceStatusData = JSON.parse(localStorage.getItem('deviceStatusData'));
			console.log(deviceStatusData);
			var deviceTypeData = JSON.parse(localStorage.getItem('deviceTypeData'));
			console.log(deviceTypeData);
			var noApplicationRecord = document.getElementById('noApplicationRecord');
			var deviceStatusID = document.getElementById('deviceStatusID');
			var shebeiDeviceSN = JSON.parse(localStorage.getItem('shebeiDeviceSN'));
			function setDiv1(item) {
				var div = '';
				if(shebeiDeviceSN.status == '正常' && item.statusID == '1'){
					div = '<option value="' + item.statusID + '"  id="' + item.statusID + '" selected = "selected">' +
						item.status +
						'</option>'
				}else if(shebeiDeviceSN.status == '异常' && item.statusID == '0'){
					div = '<option value="' + item.statusID + '"  id="' + item.statusID + '" selected = "selected">' +
						item.status +
						'</option>'
				}else{
					div = '<option value="' + item.statusID + '"  id="' + item.statusID + '">' +
						item.status +
						'</option>'
				}
				return div
			}
			function getnoApplicationData1() {
				var html = ''
				for(var i = 0; i < deviceStatusData.length; i++) {
					html += setDiv1(deviceStatusData[i])
				}
				deviceStatusID.innerHTML = html
			}
			window.onload = getnoApplicationData1()
			if (shebeiDeviceSN.deviceType == 'RFID阅读器') {
				function setDiv4(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备IP</div></div><div class="moban-lb-r"><input id="equipment11" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData4() {
						var html = ''
						html += setDiv4()
						equipment.innerHTML = html
					}
					function setDiv5(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备端口号</div></div><div class="moban-lb-r"><input id="equipment12" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData5() {
						var html = ''
						html += setDiv5()
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData4()
					window.onload = getnoApplicationData5()
			}else{
					function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备RFID号</div></div><div class="moban-lb-r"><input id="equipment13" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
							html += setDiv2()
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备编号</div></div><div class="moban-lb-r"><input id="equipment14" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>';
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						html += setDiv3();
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
				}
			console.log(shebeiDeviceSN);
			$("#noApplicationRecord").html(shebeiDeviceSN.deviceType);
			$("#deviceSN").val(shebeiDeviceSN.deviceSN);
			$("#equipment11").val(shebeiDeviceSN.ip);
			$("#equipment12").val(shebeiDeviceSN.port);
			$("#equipment13").val(shebeiDeviceSN.rfid);
			$("#equipment14").val(shebeiDeviceSN.deviceCode);
			$("#noApplicationRecord").change(function() {
				var str = $(this).children('option:selected').val();
				//			alert($(this).children('option:selected').val());
				if(str == 'RFID阅读器') {
					function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备IP</div></div><div class="moban-lb-r"><input id="equipment11" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
						html += setDiv2()
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备端口号</div></div><div class="moban-lb-r"><input id="equipment12" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						html += setDiv3()
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
					
				}else{
					function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备RFID号</div></div><div class="moban-lb-r"><input id="equipment13" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
						html += setDiv2()
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备编号</div></div><div class="moban-lb-r"><input id="equipment14" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>';
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						html += setDiv3()
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
				}
			})
		</script>
	</body>
</html>